import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import 'rxjs/add/operator/toPromise';
import {HttpServies} from '../../providers/http-servies';
import {AboutPage} from "../about/about";

@Component({
  selector: 'page-fojl',
  templateUrl: 'fojl.html',
  providers:[HttpServies]
})
export class FojlPage {
    public depositDate:any

    dataJson:any=[];
    userInfo = {
        'name': '',
        'gender': '',
        'jobinten': '',
        'education': '',
        'region': '',
        'pay': '',
        'worktime': '',
        'worktimes':'',
        'position': '',
        'company': '',
        'studytime': '',
        'studytimes': '',
        'major': '',
        'school': '',
        'self': '',
        'value':'',
        'title':'',
        'email':'',
    }

    ionViewDidLoad() {
        this.getInfo();
    }

    constructor(public navCtrl:NavController,private http:HttpServies, public navParams:NavParams) {
            this.depositDate= new Date().toISOString();
    }
    /*
    * 发布简历
    *
    * */

    checkInfo() {
        var param = "name=" + this.userInfo.name
            + "&gender=" + this.userInfo.gender
            + "&email=" + this.userInfo.email
            + "&title=" + this.userInfo.title
            + "&jobinten=" + this.userInfo.jobinten
            + "&education=" + this.userInfo.education
            + "&region=" + this.userInfo.region
            + "&pay=" + this.userInfo.pay
            + "&worktime=" + this.userInfo.worktime+"至"+this.userInfo.worktimes
            + "&position=" + this.userInfo.position
            + "&company=" + this.userInfo.company
            + "&studytime=" + this.userInfo.studytime+"至"+this.userInfo.studytimes
            + "&major=" + this.userInfo.major
            + "&school=" + this.userInfo.school
            + "&self=" + this.userInfo.self;
        this.http.httpPost('/home/Human/resume', param)
            .then(res => {
                if (res && res.code == 1) {
                    console.log(res.msg);
                    this.http.showErro(res.msg);
                    this.navCtrl.push(AboutPage);
                }else {
                    this.http.showErro(res.msg);
                }

            })
            .catch(error => {
                this.http.showErro("保存失败" + error);
            });
    }

    getInfo(){
        this.http.httpPost('/Home/human/sett')
            .then(res => {//成功
                if (res && res.code == 1) {
                    console.log(res.msg);
                    this.dataJson = res.data;
                }else {
                    this.http.showErro(res.msg);
                }
            })
    }
}

